package com.appspot.seqpop.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2011-01-23 14:15:42")
/** */
public final class AlignmentMeta extends org.slim3.datastore.ModelMeta<com.appspot.seqpop.model.Alignment> {

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.util.Date> createdDate = new org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.util.Date>(this, "createdDate", "createdDate", java.util.Date.class);

    /** */
    public final org.slim3.datastore.UnindexedAttributeMeta<com.appspot.seqpop.model.Alignment, com.appspot.seqpop.model.AlignmentDigest> digest = new org.slim3.datastore.UnindexedAttributeMeta<com.appspot.seqpop.model.Alignment, com.appspot.seqpop.model.AlignmentDigest>(this, "digest", "digest", com.appspot.seqpop.model.AlignmentDigest.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, com.google.appengine.api.datastore.Key> key = new org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, com.google.appengine.api.datastore.Key>(this, "__key__", "key", com.google.appengine.api.datastore.Key.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.util.Date> lastModifiedDate = new org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.util.Date>(this, "lastModifiedDate", "lastModifiedDate", java.util.Date.class);

    /** */
    public final org.slim3.datastore.ModelRefAttributeMeta<com.appspot.seqpop.model.Alignment, org.slim3.datastore.ModelRef<com.appspot.seqpop.model.Result>, com.appspot.seqpop.model.Result> resultRef = new org.slim3.datastore.ModelRefAttributeMeta<com.appspot.seqpop.model.Alignment, org.slim3.datastore.ModelRef<com.appspot.seqpop.model.Result>, com.appspot.seqpop.model.Result>(this, "resultRef", "resultRef", org.slim3.datastore.ModelRef.class, com.appspot.seqpop.model.Result.class);

    /** */
    public final org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.lang.Long> version = new org.slim3.datastore.CoreAttributeMeta<com.appspot.seqpop.model.Alignment, java.lang.Long>(this, "version", "version", java.lang.Long.class);

    private static final AlignmentMeta slim3_singleton = new AlignmentMeta();

    /**
     * @return the singleton
     */
    public static AlignmentMeta get() {
       return slim3_singleton;
    }

    /** */
    public AlignmentMeta() {
        super("Alignment", com.appspot.seqpop.model.Alignment.class);
    }

    @Override
    public com.appspot.seqpop.model.Alignment entityToModel(com.google.appengine.api.datastore.Entity entity) {
        com.appspot.seqpop.model.Alignment model = new com.appspot.seqpop.model.Alignment();
        model.setCreatedDate((java.util.Date) entity.getProperty("createdDate"));
        com.appspot.seqpop.model.AlignmentDigest _digest = blobToSerializable((com.google.appengine.api.datastore.Blob) entity.getProperty("digest"));
        model.setDigest(_digest);
        model.setKey(entity.getKey());
        model.setLastModifiedDate((java.util.Date) entity.getProperty("lastModifiedDate"));
        if (model.getResultRef() == null) {
            throw new NullPointerException("The property(resultRef) is null.");
        }
        model.getResultRef().setKey((com.google.appengine.api.datastore.Key) entity.getProperty("resultRef"));
        model.setVersion((java.lang.Long) entity.getProperty("version"));
        return model;
    }

    @Override
    public com.google.appengine.api.datastore.Entity modelToEntity(java.lang.Object model) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        com.google.appengine.api.datastore.Entity entity = null;
        if (m.getKey() != null) {
            entity = new com.google.appengine.api.datastore.Entity(m.getKey());
        } else {
            entity = new com.google.appengine.api.datastore.Entity(kind);
        }
        entity.setProperty("createdDate", m.getCreatedDate());
        entity.setUnindexedProperty("digest", serializableToBlob(m.getDigest()));
        entity.setProperty("lastModifiedDate", m.getLastModifiedDate());
        if (m.getResultRef() == null) {
            throw new NullPointerException("The property(resultRef) must not be null.");
        }
        entity.setProperty("resultRef", m.getResultRef().getKey());
        entity.setProperty("version", m.getVersion());
        entity.setProperty("slim3.schemaVersion", 1);
        return entity;
    }

    @Override
    protected com.google.appengine.api.datastore.Key getKey(Object model) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        return m.getKey();
    }

    @Override
    protected void setKey(Object model, com.google.appengine.api.datastore.Key key) {
        validateKey(key);
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        m.setKey(key);
    }

    @Override
    protected long getVersion(Object model) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        return m.getVersion() != null ? m.getVersion().longValue() : 0L;
    }

    @Override
    protected void assignKeyToModelRefIfNecessary(com.google.appengine.api.datastore.AsyncDatastoreService ds, java.lang.Object model) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        if (m.getResultRef() == null) {
            throw new NullPointerException("The property(resultRef) must not be null.");
        }
        m.getResultRef().assignKeyIfNecessary(ds);
    }

    @Override
    protected void incrementVersion(Object model) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        long version = m.getVersion() != null ? m.getVersion().longValue() : 0L;
        m.setVersion(Long.valueOf(version + 1L));
    }

    @Override
    protected void prePut(Object model) {
    }

    @Override
    public String getSchemaVersionName() {
        return "slim3.schemaVersion";
    }

    @Override
    public String getClassHierarchyListName() {
        return "slim3.classHierarchyList";
    }

    @Override
    protected boolean isCipherProperty(String propertyName) {
        return false;
    }

    @Override
    protected void modelToJson(org.slim3.datastore.json.JsonWriter writer, java.lang.Object model, int maxDepth, int currentDepth) {
        com.appspot.seqpop.model.Alignment m = (com.appspot.seqpop.model.Alignment) model;
        writer.beginObject();
        org.slim3.datastore.json.JsonCoder encoder = null;
        if(m.getCreatedDate() != null){
            writer.setNextPropertyName("createdDate");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getCreatedDate());
        }
        // com.appspot.seqpop.model.AlignmentDigest is not supported.
        if(m.getKey() != null){
            writer.setNextPropertyName("key");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getKey());
        }
        if(m.getLastModifiedDate() != null){
            writer.setNextPropertyName("lastModifiedDate");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getLastModifiedDate());
        }
        if(m.getResultRef() != null && m.getResultRef().getKey() != null){
            writer.setNextPropertyName("resultRef");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getResultRef(), maxDepth, currentDepth);
        }
        if(m.getVersion() != null){
            writer.setNextPropertyName("version");
            encoder = new org.slim3.datastore.json.Default();
            encoder.encode(writer, m.getVersion());
        }
        writer.endObject();
    }

    @Override
    public com.appspot.seqpop.model.Alignment jsonToModel(org.slim3.datastore.json.JsonRootReader rootReader, int maxDepth, int currentDepth) {
        com.appspot.seqpop.model.Alignment m = new com.appspot.seqpop.model.Alignment();
        org.slim3.datastore.json.JsonReader reader = null;
        org.slim3.datastore.json.JsonCoder decoder = null;
        reader = rootReader.newObjectReader("createdDate");
        decoder = new org.slim3.datastore.json.Default();
        m.setCreatedDate(decoder.decode(reader, m.getCreatedDate()));
        // com.appspot.seqpop.model.AlignmentDigest is not supported.
        reader = rootReader.newObjectReader("key");
        decoder = new org.slim3.datastore.json.Default();
        m.setKey(decoder.decode(reader, m.getKey()));
        reader = rootReader.newObjectReader("lastModifiedDate");
        decoder = new org.slim3.datastore.json.Default();
        m.setLastModifiedDate(decoder.decode(reader, m.getLastModifiedDate()));
        reader = rootReader.newObjectReader("resultRef");
        decoder = new org.slim3.datastore.json.Default();
        decoder.decode(reader, m.getResultRef(), maxDepth, currentDepth);
        reader = rootReader.newObjectReader("version");
        decoder = new org.slim3.datastore.json.Default();
        m.setVersion(decoder.decode(reader, m.getVersion()));
    return m;
}
}